FROM python:3.6

LABEL maintainer="shuc001@cmft.com"


#配置国内apt-get源
# RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak\
#     && printf 'deb http://mirrors.163.com/debian/ jessie main non-free contrib\n\
#             deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib\n\
#             deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib\n\
#             deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib\n'\
#             > /etc/apt/sources.list\


#dlib环境
RUN apt-get -y update\
    &&apt-get install -y  build-essential cmake libboost-all-dev python3-dev\
    zip unzip

#opencv
RUN apt-get update && \
        apt-get install -y \
        build-essential \
        cmake \
        git \
        wget \
        unzip \
        yasm \
        pkg-config \
        libswscale-dev \
        libtbb2 \
        libtbb-dev \
        libjpeg-dev \
        libpng-dev \
        libtiff-dev \
        libavformat-dev \
        libpq-dev

RUN pip install numpy

WORKDIR /
ENV OPENCV_VERSION="3.4.2"
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip \
&& unzip ${OPENCV_VERSION}.zip \
&& mkdir /opencv-${OPENCV_VERSION}/cmake_binary \
&& cd /opencv-${OPENCV_VERSION}/cmake_binary \
&& cmake -DBUILD_TIFF=ON \
    -DBUILD_opencv_java=OFF \
    -DWITH_CUDA=OFF \
    -DWITH_OPENGL=ON \
    -DWITH_OPENCL=ON \
    -DWITH_IPP=ON \
    -DWITH_TBB=ON \
    -DWITH_EIGEN=ON \
    -DWITH_V4L=ON \
    -DBUILD_TESTS=OFF \
    -DBUILD_PERF_TESTS=OFF \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DCMAKE_INSTALL_PREFIX=$(python3.7 -c "import sys; print(sys.prefix)") \
    -DPYTHON_EXECUTABLE=$(which python3.7) \
    -DPYTHON_INCLUDE_DIR=$(python3.7 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
    -DPYTHON_PACKAGES_PATH=$(python3.7 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
    .. \
&& make install \
&& rm /${OPENCV_VERSION}.zip \
&& rm -r /opencv-${OPENCV_VERSION}


#tensorflow环境
ADD req.txt /req/

RUN pip install -r /req/req.txt

CMD ["/bin/bash"]